<template>
	<view class="container">
		<view v-if="addressList.length > 0" class="padding-top-xs padding-bottom">
			<cu-address :list="addressList" @action="handleRoute"></cu-address>
		</view>
		<cu-blank v-else height="100vh" @action="onAddress" customStyle="borders" 
			content="暂无收货地址">
		</cu-blank>
		<view class="foot bg-white padding-sm flex flex-direction">
			<button @click="handleAdd" class="cu-btn bg-red margin-tb-sm lg">
				<text class="cuIcon-add margin-right-xs"></text>
				添加收货地址</button>
		</view>
	</view>
</template>

<script setup lang="ts">
	import cuBlank from '@/components/cu-blank.vue'
	import cuAddress from '@/components/cu-address.vue';
	import {
		ref,
		onMounted
	} from 'vue';
	import {
		onShow,
		onPullDownRefresh
	} from '@dcloudio/uni-app';
	import {
		useSettingStore
	} from '@/stores/index';
	const setting = useSettingStore();
	const addressList = ref([{
		district: '双流区',
		city: "成都市",
		province: "四川省",
		country: "中国",
		address: '关东一街1000号',
		name: '张三',
		phone: '18716643045'
	}]);
	const queryParams = ref({
		page: 1,
		size: 20
	})
	const onAddress = async () => {};
	/**
	 * 绑定用户
	 */
	const handleAdd = () => {
		uni.navigateTo({
			url: '/views/address/create'
		});
	};

	/**
	 * 点击事件
	 */
	const handleRoute = (e: any) => {
		uni.navigateTo({
			url: '/views/address/create?id=' + e.id
		});
	};
	onShow(() => {
		onAddress();
	});
	onPullDownRefresh(() => {
		queryParams.value.page = 1
		onAddress();
	});
</script>

<style></style>
